package com.transfer.conf;

import java.io.IOException;

import org.apache.log4j.PropertyConfigurator;
import org.springframework.core.io.FileSystemResourceLoader;

public class ConfigLoad {
  public static void init() {
    try {
      FileTransferProperties.load("classpath:systemConfig.properties");
      System.setProperty("WORKDIR", FileTransferProperties.getString("WORKDIR", "/"));

      PropertyConfigurator.configure(new FileSystemResourceLoader().getResource(
          "classpath:log4j.xml").getInputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public static void init(String propertyFilePath, String log4jPath) {
    try {
      // 请把加载属�?文件放在 加载日志配置的上面，因为读取日志输出的目录配置在 属�?文件里面
      // FileTransferProperties.load("classpath:systemConfig.properties");
      FileTransferProperties.load(propertyFilePath);
      System.setProperty("WORKDIR", FileTransferProperties.getString("WORKDIR", "/"));

      /*
       * PropertyConfigurator.configure(new FileSystemResourceLoader().getResource(
       * "classpath:log4j.xml").getInputStream());
       */
      PropertyConfigurator.configure(new FileSystemResourceLoader().getResource(log4jPath)
          .getInputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
